package com.xuetang9.t9.hotel.mapper;
import com.xuetang9.t9.hotel.beans.BookOrder;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IBookOrderMapper {
    /**
     * 新增
     * @param bookOrder
     * @return
     */
    @Insert("insert into e_bookOrder(customerId, bookHuman ,bookDate,bookTime,retainTime,deposit ,state,tableNum,phone) value (#{customerId},#{bookHuman},#{bookDate},#{bookTime},#{retainTime},#{deposit},#{state},#{tableNum},#{phone})")
    int insert(BookOrder bookOrder);

    /**
     * 删除
     * @param id
     * @return
     */
    @Delete("delete from e_bookOrder where id = #{id}")
    int delete(Integer id);

    /**
     * 获取所有
     * @return
     */
    @Select("select * from e_bookOrder")
    List<BookOrder> select();

    /**
     * 修改
     * @param bookOrder
     * @return
     */
    @Update("update e_bookOrder set phone = #{phone},customerId=#{customerId},tableNum=#{tableNum}, bookHuman=#{bookHuman},bookDate=#{bookDate},bookTime=#{bookTime},retainTime=#{retainTime},deposit=#{deposit} ,state=#{state} WHERE id=#{id} ")
    int alter(BookOrder bookOrder);

    /**
     * 根据查询某条数据
     * @param id
     * @return
     */
    @Select("select * from e_bookOrder where id = #{id}")
    BookOrder selectBookOrder(Integer id);


    /**
     * 获取今日预约订单
     * @return
     */
    @Select("select * from e_bookOrder where bookDate = current_date")
    List<BookOrder> todayTheOrder();

    /**
     * 通过状态获取订单
     * @return
     */
    @Select("select * from e_bookOrder where state = #{state}")
    List<BookOrder> queryByState(String state);
}
